package cc.langk.web.remote;

import cc.langk.core.util.StringUtils;
import cc.langk.web.entity.SysStaff;
import cc.langk.web.handler.TokenHandler;
import cc.langk.web.services.SysStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class IndexController {

    @Autowired
    private TokenHandler tokenHandler;
    @Autowired
    private SysStaffService sysStaffService;

    @RequestMapping("/")
    public String index() {
        return "index";
    }

    @RequestMapping("/home")
    public String home(@RequestParam String token) {
        String uid = tokenHandler.getUidByToken(token);
        if (StringUtils.isEmpty(uid)){
            return "index";
        }
        SysStaff sysStaff = sysStaffService.findOneById(Long.parseLong(uid));
        return "home";
    }


}
